<head>
	<meta charset="utf-8">

	<link href="../css/styles.css" rel="stylesheet">
	<link rel="stylesheet" href="../css/bootstrap.min.css" type="text/css">
	<link rel="stylesheet" href="../css/font-awesome.min.css" type="text/css">
	<link rel="stylesheet" href="../css/themify-icons.css" type="text/css">
	<link rel="stylesheet" href="../css/elegant-icons.css" type="text/css">
	<link rel="stylesheet" href="../css/owl.carousel.min.css" type="text/css">
	<link rel="stylesheet" href="../css/nice-select.css" type="text/css">
	<link rel="stylesheet" href="../css/jquery-ui.min.css" type="text/css">
	<link rel="stylesheet" href="../css/slicknav.min.css" type="text/css">
	<link rel="stylesheet" href="../css/style.css" type="text/css">
	<link rel="stylesheet" href="../css/susu.css" type="text/css">
	<!-- Js Plugins -->
	<script src="../js/jquery-3.3.1.min.js"></script>
	<script src="../js/bootstrap.min.js"></script>
	<script src="../js/jquery-ui.min.js"></script>
	<script src="../js/jquery.countdown.min.js"></script>
	<script src="../js/jquery.nice-select.min.js"></script>
	<script src="../js/jquery.zoom.min.js"></script>
	<script src="../js/jquery.dd.min.js"></script>
	<script src="../js/jquery.slicknav.js"></script>
	<script src="../js/owl.carousel.min.js"></script>
</head>
<body >

<!--头部引入-->
<div class="su_head ">
</div>

<br />

<div id="main-wrapper">
			
			<section class="gray pt-5 pb-5">
			<div class="container-fluid">
				<div class="row">
					<div class="col-lg-3 col-md-4 col-sm-12">
						<div class="property_dashboard_navbar">
							<div class="dash_user_avater">
								<img src="#" class="img-fluid avater" alt="" id="avater">
								<h4 id="avatername">姓名</h4>
							</div>
							<div class="dash_user_menues">
								<ul>
						
									<li ><a href="mypersonal.html"><i class="fa fa-user-tie"></i>个人信息</a></li>
									<li class="active"><a href="mycart.html"><i class="fa fa-bookmark"></i>我的收藏<span class="notti_coun style-2">7</span></a></li>
									<li><a href="myorder.html"><i class="fa fa-tasks"></i>我的交易</a></li>
									<li><a href="myinfo.html"><i class="fa fa-tasks"></i>我的发布</a></li>
					
									<li><a href="mypublish.html"><i class="fa fa-pen-nib"></i>发布信息</a></li>
									<li><a href="mypassword.html"><i class="fa fa-unlock-alt"></i>修改密码</a></li>
								</ul>
							</div>
							<div class="dash_user_footer">
								<ul>
									<li><a href="#"><i class="fa fa-power-off"></i></a></li>
									<li><a href="#"><i class="fa fa-comment"></i></a></li>
									<li><a href="#"><i class="fa fa-cog"></i></a></li>
								</ul>
							</div>
						</div>
					</div>
					
					
						<div class="col-lg-9 col-md-8 col-sm-12">
							<div class="dashboard-body">
								<div class="dashboard-wraper">
								
									<table class="property-table-wrap responsive-table bkmark">
										<tbody id="su_cart">
											<tr>
												<th><i class="fa fa-file-text"></i>我的收藏</th>
												<th></th>
												<th></th>
											</tr>
<!--											<tr>-->
<!--												<td class="dashboard_propert_wrapper">-->
<!--													<img src="#"	alt="">-->
<!--													<div class="title">-->
<!--														<h4><a href="#">Serene Uptown</a></h4><span>6 Bishop Ave.-->
<!--															Perkasie,PA </span><span class="table-property-price">$900 /-->
<!--															monthly</span>-->
<!--													</div>-->
<!--												</td>-->
<!--												<td class="action"><a href="#" class="delete"><i-->
<!--															class="ti-close"></i>Delete</a></td>-->
<!--											</tr>-->
<!--											<tr>-->
<!--												<td class="dashboard_propert_wrapper">-->
<!--													<img src="as#"alt="">-->
<!--													<div class="title">-->
<!--														<h4><a href="#">Oak Tree Villas</a></h4><span>71 Lower River Dr.-->
<!--															Bronx,NY</span><span-->
<!--															class="table-property-price">$535,000</span>-->
<!--													</div>-->
<!--												</td>-->
<!--												<td class="action"><a href="#" class="delete"><i-->
<!--															class="ti-close"></i>Delete</a></td>-->
<!--											</tr>-->




										</tbody>
									</table>
								</div>
						
							</div>
						</div>
					</div>
				</div>
			</section>
		
		</div>
	</body>
<script type="text/javascript">


	//调用公共头部
	$('.su_head').load('head.html');
	//获取导航栏信息
	$(document).ready(function () {
		$.ajax({
			type: 'get',
			url: '/ayuancity/categorys/getcategoryAndtype',
			success: function (res) {
				// console.log( $('.su_nav').text())
				for (let i = 0; i < res.content.data.length; i++) {

					let nav = res.content.data[i];
					var category =
							`
							<li id="${nav.categoryName}">
							<a href="itemsPage.html?categoryName=${nav.categoryName}">${nav.categoryName}</a>
							`;
					var drop = '';
					var type = '';
					if (nav.types.length > 0) {
						drop = ` <ul class="dropdown "  >`
						for (let j = 0; j < nav.types.length; j++) {
							type = type + `<li ><a href="itemsPage.html?categoryName=${nav.categoryName}&typeName=${nav.types[j].typeName}">${nav.types[j].typeName}</a></li>`

						}
						type = type + `</ul>`
					}
					var template = category + drop + type + ` </li>`;
					$('.su_nav').append(template);

				}
				// console.log($('.su_head').text());
			}

		})
		// 判断是否登录 已登录 显示昵称
		let citytoken = sessionStorage.getItem('citytoken');
		if (citytoken) {
			$.ajax({
				type: 'GET',
				url: '/city/user/info',
				data: {
					token: citytoken
				},
				success: function (json) {
					if (json.success) {
						let userId=json.content.user.userId;
						sessionStorage.setItem('userId',userId);
						//
						let username = json.content.user.userName;
						$('#yuan-login').html(username);
						// $('#user-showname').html(showname);
						$('#yuan-login').attr('data-toggle', 'dropdown');
						$('#yuan-userImg').removeClass("hidden");
						$('#yuan-userImg').attr("src",json.content.user.userImg);
						$('#avater').attr("src",json.content.user.userImg)
						$('#avatername').html(json.content.user.userName);

                     //收藏列表
						$.ajax({
							type: 'Get',
							url: `/ayuancity/carts/list/${userId}`,
							success: function (res) {
								console.log(res)
								for (let i = 0; i < res.content.data.total; i++) {

									let infos = res.content.data.list[i].infos[0];
									var template =
											`
							<tr>
								<td class="dashboard_propert_wrapper">
									<img src="${infos.infoImg}"	alt="" >
									<div class="title">
										<h4>
										<a href="itemDetail.html?infoId=${infos.infoId}">${infos.infoTitle}</a>
										</h4>
										<span>${infos.infoContent}</span>
										</div>
								</td>
								<td>	<span class="table-property-price">￥ ${infos.infoPrice}/ ${infos.typeName}</span>
								</td>
								<td class="action">
<!--								<a href="#" class="delete"><iclass="ti-close"></i>&nbsp;删除</a>-->
						 	<button type="button" class="btn btn-danger btn-md" onclick="deletcart(${res.content.data.list[i].id})">删除</button>
								</td>
							</tr>`;

									$('#su_cart').append(template);
								}
							}
						})
						//
					}
				}
			});
		};


	});



	function loginout() {
		$.ajax({
			type: 'POST',
			url: '/city/user/OutLogin',
			success: function (json) {
				if (json.success) {
					sessionStorage.removeItem('citytoken');
					sessionStorage.removeItem("userId")
					alert("欢迎下次登录")
					location.href = 'index.html';
				}
			}
		});
	}

	function deletcart(cartId){
		$.ajax({
			type: 'get',
			url: '/ayuancity/carts/deleteCart/'+cartId,
			success: function (json) {
				if (json.success) {

					alert("删除成功")
					location.href = 'mycart.html';
				}
			}
		});
	}
</script>
</html>
